package org.lc.stk.model.baseInfo;

import java.time.LocalDateTime;

import org.hibernate.annotations.Comment;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.PrePersist;
import jakarta.persistence.PreUpdate;
import jakarta.persistence.Table;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;

/**
 * 培养层次
 */
@Entity
@Table(name = "cengci")
@Comment("培养层次")
public class Cengci {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "id")
    private Integer id;

    @NotBlank(message = "培养层次编码不能为空")
    @Size(max = 50, message = "培养层次编码不能超过50个字符")
    @Column(name = "code", unique = true, nullable = false)
    @Comment("培养层次编码")
    private String code;

    @NotBlank(message = "培养层次名称不能为空")
    @Size(max = 100, message = "培养层次名称不能超过100个字符")
    @Column(name = "name", nullable = false)
    @Comment("培养层次名称")
    private String name;

    @Column(name = "is_deleted", columnDefinition = "boolean default false")
    @Comment("是否删除")
    private Boolean isDeleted = false;

    @Column(name = "order_num")
    @Comment("排序号")
    private Integer orderNum = 0;

    @Size(max = 500, message = "备注不能超过500个字符")
    @Column(name = "remark")
    @Comment("备注")
    private String remark;

    @Column(name = "create_time")
    @Comment("创建时间")
    private LocalDateTime createTime;

    @Column(name = "update_time")
    @Comment("更新时间")
    private LocalDateTime updateTime;

    @PrePersist
    protected void onCreate() {
        createTime = LocalDateTime.now();
        updateTime = createTime;
    }

    @PreUpdate
    protected void onUpdate() {
        updateTime = LocalDateTime.now();
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Boolean getIsDeleted() {
        return isDeleted;
    }

    public void setIsDeleted(Boolean isDeleted) {
        this.isDeleted = isDeleted;
    }

    public Integer getOrderNum() {
        return orderNum;
    }

    public void setOrderNum(Integer orderNum) {
        this.orderNum = orderNum;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public LocalDateTime getCreateTime() {
        return createTime;
    }

    public void setCreateTime(LocalDateTime createTime) {
        this.createTime = createTime;
    }

    public LocalDateTime getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(LocalDateTime updateTime) {
        this.updateTime = updateTime;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof Cengci)) return false;
        Cengci cengci = (Cengci) o;
        return getId() != null && getId().equals(cengci.getId());
    }

    @Override
    public int hashCode() {
        return getClass().hashCode();
    }

    @Override
    public String toString() {
        return "Cengci{" +
                "id=" + id +
                ", code='" + code + '\'' +
                ", name='" + name + '\'' +
                ", isDeleted=" + isDeleted +
                ", orderNum=" + orderNum +
                '}';
    }
}